import request from '@/utils/request2'




export function getParameter(): Promise<any> {
    return request({
        method: "get",
        url: "/getParameter",
    })
}

export function getTradeParameter(): Promise<any> {
    return request({
        method: "get",
        url: "/getTradeParameter",
    })
}


export function getTokenPrice(): Promise<any> {
    return request({
        method: "get",
        url: "/getTokenPrice",
    })
}

export function getNFTcount(): Promise<any> {
    return request({
        method: "get",
        url: "/getNFTcount",
    })
}

export function isUserExist(params: any): Promise<any> {
    return request({
        method: "get",
        url: "/isUserExist",
        params
    })
}

export function verifyToken(): Promise<any> {
    return request({
        method: "get",
        url: "/verifyToken",
    })
}

export function versig(params: { message: string, signature: string }): Promise<any> {
    return request({
        method: "post",
        url: "/versig",
        data: formData(params)
    })
}



export function getUserInfo(): Promise<any> {
    return request({
        method: "get",
        url: "/getUserInfo",
    })
}


export function getDirectList(params: any): Promise<any> {
    return request({
        method: "get",
        url: "/getDirectList",
        params
    })
}

export function getRewardList(params: any): Promise<any> {
    return request({
        method: "get",
        url: "/getRewardList",
        params
    })
}

export function getSendList(params: any): Promise<any> {
    return request({
        method: "get",
        url: "/getSendList",
        params
    })
}

export function getTransferList(params: any): Promise<any> {
    return request({
        method: "get",
        url: "/getTransferList",
        params
    })
}




export function transfer(params: any): Promise<any> {
    return request({
        method: "post",
        url: "/transfer",
        data: formData(params)
    })
}

export function send(params: any): Promise<any> {
    return request({
        method: "post",
        url: "/send",
        data: formData(params)
    })
}


export function insertPreInvest(params: any): Promise<any> {
    return request({
        method: "post",
        url: "/insertPreInvest",
        data: formData(params)
    })
}


export function updatePreInvest(params: any): Promise<any> {
    return request({
        method: "post",
        url: "/updatePreInvest",
        data: formData(params)
    })
}

export function getNFTList(params: any): Promise<any> {
    return request({
        method: "get",
        url: "/getNFTList",
        params
    })
}


//质押
export function getStakeParameter(): Promise<any> { ///
    return request({
        method: "get",
        url: "/getStakeParameter",
    })
}

export function createtransaction(params: any): Promise<any> {
    return request({
        method: "post",
        url: "https://api.trongrid.io/wallet/createtransaction",
        data: params
    })
}

export function insertPreStake(params: any): Promise<any> {//
    return request({
        method: "post",
        url: "/insertPreStake",
        data: formData(params)
    })
}

export function updatePreStake(params: any): Promise<any> {//
    return request({
        method: "post",
        url: "/updatePreStake",
        data: formData(params)
    })
}

export function getStakeList(params: any): Promise<any> {//
    return request({
        method: "get",
        url: "/getStakeList",
        params
    })
}

export function updateStake(params: any): Promise<any> {//
    return request({
        method: "post",
        url: "/updateStake",
        data: formData(params)
    })
}


export function getTradeRecordList(params: any): Promise<any> {//
    return request({
        method: "get",
        url: "/getTradeRecordList",
        params
    })
}

// export function send(params: any): Promise<any> {//
//     return request({
//         method: "post",
//         url: "/send",
//         data: formData(params)
//     })
// }

export function getStakeInfo(): Promise<any> {//
    return request({
        method: "get",
        url: "/getStakeInfo",
    })
}

// export function getSendList(params: any): Promise<any> {//
//     return request({
//         method: "get",
//         url: "/getSendList",
//         params
//     })
// }




const formData = (params: any) => {
    let formData = new FormData();
    for (let i in params) {
        formData.append(i, params[i])
    }
    return formData
}